package com.nuaa.dao.ret.impl;

import java.util.Date;

import javax.transaction.Transactional;

import org.springframework.stereotype.Repository;

import com.nuaa.dao.base.impl.BaseDaoImpl;
import com.nuaa.dao.ret.inter.ReturnDaoInter;
import com.nuaa.domain.ret.ReturnEntity;
import com.nuaa.utils.AjaxMsg;
import com.nuaa.utils.CustomCodeUtil;
/**退货Dao*/
@Repository("returnDao")
public class ReturnDaoImpl extends BaseDaoImpl<ReturnEntity, Integer>implements ReturnDaoInter{
	/**保存一条订单信息*/
	@Override
	@Transactional
	public AjaxMsg saveOrder(ReturnEntity entity) {
		AjaxMsg msg = new AjaxMsg();
		try{
			String RE_NO = CustomCodeUtil.getReturnOrderNo(this.getMaxId(entity.getClass()));
			entity.setOrder_no(RE_NO);
			entity.setCreate_tm(new Date());
			entity.setBusiness_type("FBA退货业务");
			this.save(entity);
			msg.setSuccess(true);
			msg.setResult(RE_NO);
			msg.setMsg("提交成功！");
		}catch(Exception e){
			msg.setSuccess(false);
			e.printStackTrace();
			
			msg.setMsg("提交失败！");
		}
		return msg;
	}
}
